﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lesson4_封装_构造函数以及析构函数
{
    internal class Program
    {
        //析构函数是垃圾真正被回收的时候才会被调用的函数
        //无参构造函数
        //类中是可以申明午参构造函数的
        class Person
        {
            public int age;
            public string name;    
            public Person()
            {
                name = "唐老师";
                age = 18;
            }
           public Person(int age)
            {
                this.age = age;
            }
            public Person(string name)
            {
                this.name = name;
            }
            public Person(string name, int age):this()   //先调用某个函数
            {
                Console.WriteLine("Person两个函数参数调用");
            }
        }

        static void Main(string[] args)
        {   
           Person p =new Person();
           Console.WriteLine(p.name);
        }
    }
}
